<?php
$currdate = date('Y-m-d');
$type = My_Utils::getRequestParam('type');
$startDate = My_Utils::getRequestParam('start_date', $currdate);
$weekendStart = My_DateUtil::getNearestFriday($startDate);
$weekendEnd = My_DateUtil::addDate($weekendStart, 2);
?>
<div class="row-fluid event-calendar">
    <div class="span6">
        <div class="eventCalendar"></div>
    </div>
    <div class="span2 shortcuts">
        <ul>
            <li><a href="<?= $this->url(array('controller' => 'event', 'action' => 'index', 'start_date' => $currdate), 'default') ?>">Dzisiaj</a></li>
            <li><a href="<?= $this->url(array('controller' => 'event', 'action' => 'index', 'start_date' => date('Y-m-d', time() + 24 * 60 * 60)), 'default') ?>">Jutro</a></li>
            <li><a href="<?= $this->url(array('controller' => 'event', 'action' => 'index', 'start_date' => date('Y-m-d', time() + 2 * 24 * 60 * 60)), 'default') ?>">Pojutrze</a></li>
            <li><a href="<?= $this->url(array('controller' => 'event', 'action' => 'index', 'start_date' => $weekendStart, 'end_date' => $weekendEnd), 'default') ?>">Weekend</a></li>
        </ul>
    </div>
    <div class="span4 calendar-pic">
        <img src="/graph/event/calendar-pic.jpg" alt="" />
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $('.eventCalendar').datepicker({
            dateFormat: 'yy-mm-dd',
            firstDay: 1,
            onSelect: function(date, obj) {
                var url = '/event/index/<?= $type ? 'type/' . $type . '/' : '' ?>';
                url += 'start_date/' + date;
                document.location = url;
            }
        });
        <?php if (isset($startDate)): ?>
                $('.eventCalendar').datepicker( "setDate", $.datepicker.parseDate( "yy-mm-dd", '<?= $startDate ?>' ));
        <?php endif; ?>
        
    });
</script>